package com.card.manager.controller;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.card.framework.page.model.PageModel;
import com.card.framework.util.ReportUtil;
import com.card.manager.domain.Maf;
import com.card.manager.services.MafService;

@Controller
@RequestMapping("/maf")
public class MafController {
	@Autowired(required=true) 
	private MafService mafServices;
	@RequestMapping("/index")
	public String aaa(){
		return "mafList";
	}
	@RequestMapping(value="/queryList",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> queryList(Maf maf,PageModel pageModel){
		return mafServices.selectMafForPage(maf, pageModel);
	}
	@SuppressWarnings("rawtypes")
	@RequestMapping(value="/exportOperCardForPdf",method=RequestMethod.POST)
	public void exportChangeCardForPdf(Maf maf,HttpServletResponse response) {
		InputStream inputStream =   this.getClass().getClassLoader().getResourceAsStream("reports/operentCardReport.jasper");
		ReportUtil.exportPdf("换卡报表", inputStream, response, new HashMap(), mafServices.selectMafForPrint(maf));
	}
	@SuppressWarnings("rawtypes")
	@RequestMapping(value="/exportOperCardForExcel",method=RequestMethod.POST)
	public void exportChangeCardForExcel(Maf maf,HttpServletResponse response) {
		 InputStream inputStream =   this.getClass().getClassLoader().getResourceAsStream("reports/operentCardReport.jasper");
		 ReportUtil.exportExcel("换卡报表", inputStream, response, new HashMap(), mafServices.selectMafForPrint(maf));
	}
}
